<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <div id="app"></div>
    <!-- 1.引入依赖 -->
    <script src="../../react/react.development.js"></script>
    <script src="../../react/react-dom.development.js"></script>
    <script src="../../react/babel.min.js"></script>
    <!-- 2.开始开发 -->
    <script type="text/babel">
      // JSX要渲染的元素只能有一个根元素

      let message = 'Hello World'
      function render() {
        ReactDOM.render(
          <div>
            <h2>{message}</h2>
            <button onClick={btnClick}>改变文本</button>
          </div>,
          document.getElementById("app")
        )
      }

      function btnClick() {
        message = 'Hello React'
        render()
      }

      render()
    </script>
  </body>
</html>
